package com.small.nacos.client.config.impl;

import com.alibaba.nacos.api.PropertyKeyConst;
import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.common.lifecycle.Closeable;
import small.common.core.util.StringUtil;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;

/**
 * @Author zhoujin
 * @Date 2022/11/22 16:04
 */
public class ServerListManager implements Closeable {


    private static int DEFAULT_SERVER_PORT = 8858;

    private static String name = "default";

    private static String contentPath = "/nacos";

    private List<String> serverList = new ArrayList<>();

    public ServerListManager(Properties properties) {
        String serviceStr = properties.getProperty(PropertyKeyConst.SERVER_ADDR);
        if (StringUtil.isNotBlank(serviceStr)) {
            this.serverList = Arrays.asList(serviceStr.split(","));
        }
    }

    public List<String> getCurrentServerAddr() {
        return serverList;
    }

    @Override
    public void shutdown() throws NacosException {

    }

    public String getName() {
        return name;
    }

    public static String getContentPath() {
        return contentPath;
    }
}
